package movieGandalf.dataObjects;

import java.math.BigInteger;

import java.sql.*;

import movieGandalf.database.MovieTools;
import movieGandalf.logicGuiConnection.*;

public class RoleImp implements Role{
	private BigInteger movieID;
	private BigInteger actorID;
	private String role;
	
	
	/*constructor*/
	
	public RoleImp(BigInteger movieID,BigInteger actorID, String role){
		this.movieID = movieID;
		this.actorID = actorID;
		this.role = role;
	}
	
	
	/*getters*/
	
	public Object getID(){
		return null; // Not in use for this Class.
	}
	
	public BigInteger getMovieID(){
		return movieID;
	}
	
	public BigInteger getActorID(){
		return actorID;
	}
	
	public String getRole(){
		return role;
	}

	public Movie getMovie(){
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return null;
		
		return MovieTools.getMovie(conn, this.getMovieID());
	}

	public Actor getActor(){
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return null;
		
		return MovieTools.getActor(conn, this.getActorID());
	}
	
	/*setters*/
	
	public void setMovie(BigInteger movieID){
		this.movieID = movieID;
	}
	
	public void setActor(BigInteger actorID){
		this.actorID = actorID;
	}
	
	public void setRoleName(String role){
		this.role = role;
	}

	public boolean update() {
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return false;
		
		return MovieTools.updateRole(conn, this);
	}
	
	public boolean delete() {
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return false;
		
		return MovieTools.deleteObject(conn,this);
	}
}
